package com.exercise.widgets.recyclerview.selection.selector

import android.view.MotionEvent
import androidx.recyclerview.selection.ItemDetailsLookup
import androidx.recyclerview.widget.RecyclerView
import com.exercise.widgets.recyclerview.selection.adapter.ContactAdapter
import com.exercise.widgets.recyclerview.selection.entity.Contact

class ContactItemDetailLookup(
    private val recyclerView: RecyclerView
) : ItemDetailsLookup<Contact>() {
    override fun getItemDetails(e: MotionEvent): ItemDetails<Contact>? {
        val itemView = recyclerView.findChildViewUnder(e.x, e.y)
        return itemView?.let {
            (recyclerView.getChildViewHolder(itemView) as? ContactAdapter.ContactViewHolder)?.getItemDetail()
        }
    }
}